package com.liujit.bms.admin.controller;

import com.liujit.bms.admin.service.BlogMemberService;
import com.liujit.bms.admin.domain.query.BlogMemberQuery;
import com.liujit.bms.admin.domain.result.BlogMemberResult;
import com.liujit.common.domain.params.BaseParams;
import com.liujit.common.domain.result.PageBean;
import io.swagger.annotations.*;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 博客会员管理接口
 * @Author liujun
 * @Date 2021-07-02 14:27:58
 */
@RequiredArgsConstructor
@Api(tags = "博客会员管理接口")
@RestController
@RequestMapping("/blog/member")
public class BlogMemberController {

    private final BlogMemberService blogMemberService;

    @ApiOperation(value = "分页查询", notes = "根据博客会员分页查询条件，分页查询博客会员列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "query", value = "博客会员分页查询条件", dataType = "BlogMemberQuery", dataTypeClass = BlogMemberQuery.class, paramType = "query") })
    @GetMapping("/getPage")
    public PageBean<BlogMemberResult> getPage(BlogMemberQuery query) {
        return blogMemberService.getPage(query);
    }

    @ApiOperation(value = "查询详情", notes = "根据博客会员id，查询博客会员")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "博客会员id", dataType = "Long", dataTypeClass = Long.class, paramType = "query") })
    @GetMapping("/getDetail")
    public BlogMemberResult getDetail(Long id) {
        return blogMemberService.getDetail(id);
    }

    @ApiOperation(value = "启用", notes = "根据博客会员启用请求参数，启用博客会员")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "params", value = "博客会员启用请求参数", dataType = "BaseParams", dataTypeClass = BaseParams.class, paramType = "body") })
    @PostMapping("/enabled")
    public Boolean enabled(@RequestBody BaseParams params) {
        return blogMemberService.enabled(params);
    }

    @ApiOperation(value = "禁用", notes = "根据博客会员禁用请求参数，禁用博客会员")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "params", value = "博客会员禁用请求参数", dataType = "BaseParams", dataTypeClass = BaseParams.class, paramType = "body") })
    @PostMapping("/disabled")
    public Boolean disabled(@RequestBody BaseParams params) {
        return blogMemberService.disabled(params);
    }
}
